package com.ice.cloud.hotelManagement.sentinelController;

import com.alibaba.csp.sentinel.adapter.spring.webmvc.callback.RequestOriginParser;
import jakarta.servlet.http.HttpServletRequest;
import org.springframework.stereotype.Component;

@Component  //示这是一个 Spring 组件，会被自动扫描并注册到 Spring 容器中
public class MyRequestOriginParser implements RequestOriginParser {  //用于从 HTTP 请求中解析请求来源(origin)
    @Override
    public String parseOrigin(HttpServletRequest httpServletRequest) {
        //这个方法从 HTTP 请求中获取 userId 参数作为请求的来源标识
        return httpServletRequest.getParameter("userId");
    }
}
